home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 June: Reference Library / Dev.CD Jun 99 RL Disk 1.toast / Technical Documentation / Develop / Additional Articles / Developing Symbiotic Apps / Symbiotic Samples / Symbiotic server source / flexibled & simpled / debug.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-03  |  1.1 KB  |  57 lines  |  [TEXT/CWIE]

  1. /* debug.h -- header for simplified debug output.
  2.  *
  3.  * %W%
  4.  *
  5.  * Author: Chris Jalbert
  6.  * Copyright 1996 Apple Computer, Inc.
  7.  * All Rights Reserved.
  8.  *
  9.  * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF APPLE COMPUTER, INC.
  10.  * The copyright notice above does not evidence any actual or
  11.  * intended publication of such source code.
  12.  */
  13.  
  14. #ifndef _DEBUG_H_
  15. #define _DEBUG_H_
  16.  
  17. #ifndef _DEBUG
  18. #define _DEBUG 0
  19. #endif
  20.  
  21. #if _DEBUG
  22.  
  23. #include <stdio.h>
  24. #include <stdarg.h>
  25.  
  26. extern FILE *__DebugFile;
  27. static char *tprintf (char *format, ...)
  28. {
  29. static char    _buffer[512];
  30. va_list        args;
  31.  
  32.     va_start(args, format);
  33.     vsprintf(_buffer, format, args);
  34.     va_end(args);
  35.     return _buffer;
  36. }
  37.  
  38. #define DBGSetup(path) __DebugFile = fopen (path, "w")
  39. #define DBGPause(secs)    sleep (secs)
  40. #define DBGClose()        fclose (__DebugFile)
  41. #define DBG(x,a)        (__DebugFile == NULL) ? 0    \
  42.                             : fprintf (__DebugFile, x, a), fflush (__DebugFile)
  43. #define DBGM(x)            (__DebugFile == NULL) ? 0    \
  44.                             : fputs (x, __DebugFile), fflush (__DebugFile)
  45.  
  46. #else    /* !_DEBUG */
  47.  
  48. #define DBGSetup(path)
  49. #define DBGPause(secs)
  50. #define DBGClose()
  51. #define DBG(x,a)
  52. #define DBGM(x)
  53.  
  54. #endif    /* _DEBUG */
  55.  
  56. #endif    /* _DEBUG_H_ */
  57.